import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Field, reduxForm } from 'redux-form';
import { FormattedMessage, injectIntl } from 'react-intl';
import { TextField, Row, Col, Button } from '@folio/stripes/components';

class FruitPack extends Component {
  static propTypes = {
    handleSubmit: PropTypes.func.isRequired,
    intl: PropTypes.func.isRequired
  };

  fieldChange = () => {
    const { handleSubmit } = this.props;
    this.setState(() => {
      handleSubmit();
    });
  };

  render() {
    const { handleSubmit, intl, labelName } = this.props;
    return (

        <form data-test-form-page id="form-search" onSubmit={handleSubmit}>
          <Row style={{ width: '100%' }}>
            <Col xs={11}>
              <Field
                component={TextField}
                name="partyName"
                placeholder={intl.formatMessage({ id: 'ui-party.loans.columns.party.partyName' })}
                onBlur={this.fieldChange}
                onClearField={this.fieldChange}
              />
            </Col>
            <Col xs={1}>
              <Button type="submit">
                  {intl.formatMessage({ id: 'ui-party.search' })}
              </Button>
            </Col>
          </Row>
        </form>

    );
  }
}

export default injectIntl(
  reduxForm({
    form: 'ActivitySearchFrom01',
    navigationCheck: true,
    enableReinitialize: true
  })(FruitPack)
);
